package com.gec.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gec.mapper.ArticleMapper;
import com.gec.service.ArticleService;
import com.gec.pojo.Article;


@Service
public class ArticleServiceImpl implements ArticleService{
	
	@Autowired
	ArticleMapper articleMapper;

	@Override
	public int getArticleCount(String typecode, String keyword) {
		return articleMapper.getArticleCount(typecode,keyword);
	}

	@Override
	public List<Article> getArticleByPage(String typecode, String keyword, int currentPage, int pageSize) {
		int start = (currentPage-1)*pageSize;
		return articleMapper.getArticleByPage(typecode, keyword,start,pageSize);
	}

	@Override
	public Article getArticleById(int id) {
		return articleMapper.getArticleById(id);
	}

	@Override
	public List<Article> getArticles() {
		return articleMapper.getArticles();
	}

	@Override
	public List<Article> getArticleByType(String string) {
		return articleMapper.getArticleByType(string);
	}

	@Override
	public void postArticle(String title, String text, String name, String typecode) {
		articleMapper.postArticle(title,text,name,typecode);
	}

	@Override
	public void deleteArticle(int aid) {
		articleMapper.deleteArticle(aid);
	}

	@Override
	public Article getNewestArticle() {
		return articleMapper.getNewestArticle();
	}

	@Override
	public void updateArticle(int aid, String title, String text) {
		articleMapper.updateArticle(aid,title,text);
	}

	@Override
	public List<Article> getArticleByName(String name) {
		return articleMapper.getArticleByName(name);
	}


}
